//2009/08/30 21:51:36
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class UnluckyNumbers
{
public:
    int getCount(vector <int> s, int n)
    {
        sort(s.begin(), s.end());
        if (n < s[0]) return n * (s[0] - n) - 1;
        for (int i=0; i<s.size(); i++)
        {
            if (s[i] == n) return 0;
            if (s[i] < n && n < s[i+1])
                return (n-s[i]) * (s[i+1]-n) -1;
        }
    }
};
